package cn.iocoder.yudao.module.system.dal.mysql.workstore;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.workstore.WorkStoreDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.workstore.vo.*;

/**
 * 工单入库 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface WorkStoreMapper extends BaseMapperX<WorkStoreDO> {

    default PageResult<WorkStoreDO> selectPage(WorkStorePageReqVO reqVO) {
        PageResult<WorkStoreDO> data = new PageResult<>();
        if(reqVO.getListType()==null||reqVO.getListType()==1){
            data = selectPage(reqVO, new LambdaQueryWrapperX<WorkStoreDO>()
                    .gtIfPresent(WorkStoreDO::getTotalQuantity, 0)
                    .eqIfPresent(WorkStoreDO::getWorkId, reqVO.getWorkId())
                    .eqIfPresent(WorkStoreDO::getStorageMethod, reqVO.getStorageMethod())
                    .eqIfPresent(WorkStoreDO::getTotalQuantity, reqVO.getTotalQuantity())
                    .eqIfPresent(WorkStoreDO::getStorageEquipment, reqVO.getStorageEquipment())
                    .eqIfPresent(WorkStoreDO::getBatchNumber, reqVO.getBatchNumber())
                    .eqIfPresent(WorkStoreDO::getRacking, reqVO.getRacking())
                    .eqIfPresent(WorkStoreDO::getRemarks, reqVO.getRemarks())
                    .betweenIfPresent(WorkStoreDO::getCreateTime, reqVO.getCreateTime())
                    .orderByDesc(WorkStoreDO::getId));
        } else {
            data = selectPage(reqVO, new LambdaQueryWrapperX<WorkStoreDO>()
                    .ltIfPresent(WorkStoreDO::getTotalQuantity, 0)
                    .eqIfPresent(WorkStoreDO::getWorkId, reqVO.getWorkId())
                    .eqIfPresent(WorkStoreDO::getStorageMethod, reqVO.getStorageMethod())
                    .eqIfPresent(WorkStoreDO::getTotalQuantity, reqVO.getTotalQuantity())
                    .eqIfPresent(WorkStoreDO::getStorageEquipment, reqVO.getStorageEquipment())
                    .eqIfPresent(WorkStoreDO::getBatchNumber, reqVO.getBatchNumber())
                    .eqIfPresent(WorkStoreDO::getRacking, reqVO.getRacking())
                    .eqIfPresent(WorkStoreDO::getRemarks, reqVO.getRemarks())
                    .betweenIfPresent(WorkStoreDO::getCreateTime, reqVO.getCreateTime())
                    .orderByDesc(WorkStoreDO::getId));
        }
        return data;
    }

}
